<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
    <title>Jumper</title>
    <link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

<div id="container">

<div id="product">
	<div id="product_logo"></div>
	<div id="product_name"><big><b></b></big></div>
	<div id="product_description"></div>
</div> <!-- id="product" -->


<div id="main">


<!-- Menu -->

<div id="navigation">
<br/>
<h1>Jumper</h1>

<ul>
  <li><a href="../index.html">Index</a></li>
</ul>

<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
</ul>


<h2>Scripts</h2>
<ul>
  <li><strong>grid</strong></li>
  <li><a href="../scripts/heuristics.html">heuristics</a></li>
  <li><a href="../scripts/jumper.html">jumper</a></li>
</ul>
<h2>Modules</h2>
<ul>
  <li><a href="../modules/core.bheap.html">core.bheap</a></li>
  <li><a href="../modules/init.html">init</a></li>
</ul>

</div>

<div id="content">

<h1>Script <code>grid</code></h1>

<p><strong>The <code>grid</code> class API</strong>.</p>
<p> This file contains the implementation of a <a href="../scripts/grid.html#">grid</a>  class, internally used by the
 search algorithm. The grid is automatically generated upon initialization of the
 <code>pathfinder</code> object, passing it a mandatory collision map.
 During a search, the pathfinder evaluates costs values for each node being processed, in order to
 select, after each step of iteration, what node should be expanded next to reach the target
 optimally. Those values are cached within an array stored in the <a href="../scripts/grid.html#">grid</a>  object.
 </p>
    <h3>Info:</h3>
    <ul>
        <li><strong>Copyright</strong>: 2012-2013</li>
        <li><strong>License</strong>: <a href="http://www.opensource.org/licenses/mit-license.php">MIT</a></li>
        <li><strong>Author</strong>: Roland Yonaba</li>
    </ul>


<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#grid:new">grid:new&nbsp;(map[, walkable[, processGridOnline]])</a></td>
	<td class="summary">Inits a new <a href="../scripts/grid.html#">grid</a>  object</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:isWalkableAt">grid:isWalkableAt&nbsp;(x, y)</a></td>
	<td class="summary">Checks if node [x,y] exists on the collision map and is walkable</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:setWalkableAt">grid:setWalkableAt&nbsp;(x, y, walkable)</a></td>
	<td class="summary">Sets node [x,y] as walkable or not</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:getNeighbours">grid:getNeighbours&nbsp;(node[, allowDiagonal])</a></td>
	<td class="summary">Returns the neighbours of a given node on a grid</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:iter">grid:iter&nbsp;([lx[, ly[, ex[, ey]]]])</a></td>
	<td class="summary">Iterates on nodes on the grid.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:eachRange">grid:eachRange&nbsp;(lx, ly, ex, ey, f[, ...])</a></td>
	<td class="summary">Executes a function on each node in the range of a rectangle of cells, passing the node as the first arg to function <code>f</code>.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:imap">grid:imap&nbsp;(f[, ...])</a></td>
	<td class="summary">Maps <code>f(node,...)</code> on each node in a given range, passing the node as the first arg to function <code>f</code>.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:imapRange">grid:imapRange&nbsp;(lx, ly, ex, ey, f[, ...])</a></td>
	<td class="summary">Maps <code>f(node,...)</code> on each node in the range of a rectangle of cells, passing the node as the first arg to function <code>f</code>.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:getNodeAt">grid:getNodeAt&nbsp;(x, y)</a></td>
	<td class="summary">Returns the node[x,y] on a <a href="../scripts/grid.html#">grid</a> .</td>
	</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#grid">grid</a></td>
	<td class="summary">The <a href="../scripts/grid.html#">grid</a>  class</td>
	</tr>
</table>

<br/>
<br/>


    <h2><a name="Functions"></a>Functions</h2>

    <dl class="function">
    <dt>
    <a name = "grid:new"></a>
    <strong>grid:new&nbsp;(map[, walkable[, processGridOnline]])</strong>
    </dt>
    <dd>
    Inits a new <a href="../scripts/grid.html#">grid</a>  object

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">map</span>
        <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
       A collision map - (2D array) with consecutive integer indices</li>
      <li><span class="parameter">walkable</span>
        <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">int</span></span>
       the value for walkable nodes on the passed-in map array</li>
      <li><span class="parameter">processGridOnline</span>
        <span class="types"><span class="type">bool</span></span>
       whether or not the internal grid object should be processed online</li>
    </ul>

    <h3>Returns:</h3>
    <ol>

          <span class="types"><a class="type" href="../scripts/grid.html#">grid</a></span>
        a new <a href="../scripts/grid.html#">grid</a>  object
    </ol>




</dd>
    <dt>
    <a name = "grid:isWalkableAt"></a>
    <strong>grid:isWalkableAt&nbsp;(x, y)</strong>
    </dt>
    <dd>
    Checks if node [x,y] exists on the collision map and is walkable

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">x</span>
        <span class="types"><span class="type">int</span></span>
       the x-coordinate of the node</li>
      <li><span class="parameter">y</span>
        <span class="types"><span class="type">int</span></span>
       the y-coordinate of the node</li>
    </ul>

    <h3>Returns:</h3>
    <ol>

          <span class="types"><span class="type">bool</span></span>
        <code>true</code> if the node exist and is walkable, <code>false</code> otherwise
    </ol>




</dd>
    <dt>
    <a name = "grid:setWalkableAt"></a>
    <strong>grid:setWalkableAt&nbsp;(x, y, walkable)</strong>
    </dt>
    <dd>
    Sets node [x,y] as walkable or not

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">x</span>
        <span class="types"><span class="type">int</span></span>
       the x-coordinate of the node</li>
      <li><span class="parameter">y</span>
        <span class="types"><span class="type">int</span></span>
       the y-coordinate of the node</li>
      <li><span class="parameter">walkable</span>
        <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">int</span></span>
       the value to be set on the collision map for the node [x,y]</li>
    </ul>





</dd>
    <dt>
    <a name = "grid:getNeighbours"></a>
    <strong>grid:getNeighbours&nbsp;(node[, allowDiagonal])</strong>
    </dt>
    <dd>
    Returns the neighbours of a given node on a grid

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">node</span>
        <span class="types"><span class="type">node</span></span>
       <code>node</code> object</li>
      <li><span class="parameter">allowDiagonal</span>
        <span class="types"><span class="type">bool</span></span>
       whether or not 8-directions movements is allowed</li>
    </ul>

    <h3>Returns:</h3>
    <ol>

          <span class="types"><span class="type">{node,...}</span></span>
        an array of nodes neighbouring a passed-in node on the collision map
    </ol>




</dd>
    <dt>
    <a name = "grid:iter"></a>
    <strong>grid:iter&nbsp;([lx[, ly[, ex[, ey]]]])</strong>
    </dt>
    <dd>
    Iterates on nodes on the grid.  When given no args, will iterate on every single node
 on the grid, in case the grid is pre-processed. Passing <code>lx, ly, ex, ey</code> args will iterate
 on nodes inside a bounding-rectangle delimited by those coordinates.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">lx</span>
        <span class="types"><span class="type">int</span></span>
       the leftmost x-coordinate coordinate of the rectangle</li>
      <li><span class="parameter">ly</span>
        <span class="types"><span class="type">int</span></span>
       the topmost y-coordinate of the rectangle</li>
      <li><span class="parameter">ex</span>
        <span class="types"><span class="type">int</span></span>
       the rightmost x-coordinate of the rectangle</li>
      <li><span class="parameter">ey</span>
        <span class="types"><span class="type">int</span></span>
       the bottom-most y-coordinate of the rectangle</li>
    </ul>

    <h3>Returns:</h3>
    <ol>

          <span class="types"><span class="type">node</span></span>
        a node on the collision map, upon each iteration step
    </ol>




</dd>
    <dt>
    <a name = "grid:eachRange"></a>
    <strong>grid:eachRange&nbsp;(lx, ly, ex, ey, f[, ...])</strong>
    </dt>
    <dd>
    Executes a function on each node in the range of a rectangle of cells, passing the node as the first arg to function <code>f</code>.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">lx</span>
        <span class="types"><span class="type">int</span></span>
       the leftmost x-coordinate coordinate of the rectangle</li>
      <li><span class="parameter">ly</span>
        <span class="types"><span class="type">int</span></span>
       the topmost y-coordinate of the rectangle</li>
      <li><span class="parameter">ex</span>
        <span class="types"><span class="type">int</span></span>
       the rightmost x-coordinate of the rectangle</li>
      <li><span class="parameter">ey</span>
        <span class="types"><span class="type">int</span></span>
       the bottom-most y-coordinate of the rectangle</li>
      <li><span class="parameter">f</span>
        <span class="types"><span class="type">function</span></span>
       a function prototyped as <code>f(node,...)</code></li>
      <li><span class="parameter">...</span>
        <span class="types"><span class="type">vararg</span></span>
       args to be passed to function <code>f</code></li>
    </ul>





</dd>
    <dt>
    <a name = "grid:imap"></a>
    <strong>grid:imap&nbsp;(f[, ...])</strong>
    </dt>
    <dd>
    Maps <code>f(node,...)</code> on each node in a given range, passing the node as the first arg to function <code>f</code>.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">f</span>
        <span class="types"><span class="type">function</span></span>
       a function prototyped as <code>f(node,...)</code></li>
      <li><span class="parameter">...</span>
        <span class="types"><span class="type">vararg</span></span>
       args to be passed to function <code>f</code></li>
    </ul>





</dd>
    <dt>
    <a name = "grid:imapRange"></a>
    <strong>grid:imapRange&nbsp;(lx, ly, ex, ey, f[, ...])</strong>
    </dt>
    <dd>
    Maps <code>f(node,...)</code> on each node in the range of a rectangle of cells, passing the node as the first arg to function <code>f</code>.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">lx</span>
        <span class="types"><span class="type">int</span></span>
       the leftmost x-coordinate coordinate of the rectangle</li>
      <li><span class="parameter">ly</span>
        <span class="types"><span class="type">int</span></span>
       the topmost y-coordinate of the rectangle</li>
      <li><span class="parameter">ex</span>
        <span class="types"><span class="type">int</span></span>
       the rightmost x-coordinate of the rectangle</li>
      <li><span class="parameter">ey</span>
        <span class="types"><span class="type">int</span></span>
       the bottom-most y-coordinate of the rectangle</li>
      <li><span class="parameter">f</span>
        <span class="types"><span class="type">function</span></span>
       a function prototyped as <code>f(node,...)</code></li>
      <li><span class="parameter">...</span>
        <span class="types"><span class="type">vararg</span></span>
       args to be passed to function <code>f</code></li>
    </ul>





</dd>
    <dt>
    <a name = "grid:getNodeAt"></a>
    <strong>grid:getNodeAt&nbsp;(x, y)</strong>
    </dt>
    <dd>
    Returns the node[x,y] on a <a href="../scripts/grid.html#">grid</a> .

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">x</span>
        <span class="types"><span class="type">int</span></span>
       the x-coordinate coordinate</li>
      <li><span class="parameter">y</span>
        <span class="types"><span class="type">int</span></span>
       the y-coordinate coordinate</li>
    </ul>

    <h3>Returns:</h3>
    <ol>

          <span class="types"><span class="type">node</span></span>
        a <code>node</code> object <br/>
 Gets the node at location <x,y> on a preprocessed grid
    </ol>




</dd>
</dl>
    <h2><a name="Tables"></a>Tables</h2>

    <dl class="function">
    <dt>
    <a name = "grid"></a>
    <strong>grid</strong>
    </dt>
    <dd>
    The <a href="../scripts/grid.html#">grid</a>  class

    <h3>Fields:</h3>
    <ul>
      <li><span class="parameter">width</span>
       The grid width</li>
      <li><span class="parameter">height</span>
       The grid height</li>
      <li><span class="parameter">walkable</span>
       The value for walkable nodes</li>
      <li><span class="parameter">map</span>
       A reference to the collision map</li>
      <li><span class="parameter">nodes</span>
       A 2D array of nodes, each node matching a cell on the collision map</li>
    </ul>





</dd>
</dl>


</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.3</a></i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>
